package com.taxigang.server;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.allen_sauer.gwt.log.client.Log;

public class CountryServlet extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final String UP = "../";
	private CountryLang countryLang = new CountryLang();
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
	throws IOException {
		String country = req.getHeader("X-AppEngine-Country");
		String lang = countryLang.getLang(country);

		final String ip = req.getRemoteAddr();
		Log.info("LOGIN:"+ip+" lang:"+lang+"  country:"+country);

		
		String prefix = "";
		
		if (req.getRequestURL().indexOf("taxiganggwt") >=0){
			prefix = UP;
		}
		String redirect = prefix+"?locale="+lang+"&co="+country;
		resp.sendRedirect(redirect);
	}
}